<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2022-12-28 17:43:07
 * @Last Modified time: 2023-02-13 18:21:33
 */
namespace app\common\model\store;

use frank\base\BaseModel;
use frank\traits\ModelTrait;
use app\common\enum\EnumFactory;

/**
 * 商城-商品sku
 * Class GoodsSkuModel
 * @package app\common\model\store
 */
class GoodsSkuModel extends BaseModel
{
    use ModelTrait;

    /**
     * 数据表主键
     */
    protected $pk = 'id';

    /**
     * 模型名称
     */
    protected $name = 'store_goods_sku';


    /**
     * 获取器
     */
    public function getSkuAttrTextAttr($value){
        return empty($value)?'默认':$value;
    }


    /**
     * id搜索器
     */
    public function searchIdAttr($query, $value)
    {
        if (is_array($value)) {
            $query->whereIn('id', $value);
        } else {
            $query->where('id', $value);
        }
    }

    /**
     * goods_id搜索器
     */
    public function searchGoodsIdAttr($query, $value)
    {
        if (is_array($value)) {
            $query->whereIn('goods_id', $value);
        } else {
            $query->where('goods_id', $value);
        }
    }

}
